﻿package app.view.components.buttons 
{
	import flash.display.MovieClip;
	import flash.text.TextField;
	
	/**
	 * Выделяемая кнопка
	 * @author firsoff maxim, tel: +79222345364, skype: maxim.firsoff
	 */
	public class SelectableButton extends MovieClip
	{
		// app.view.components.buttons.SelectableButton
		
		private var _selected:Boolean;
		private var _data:Object;
		public var id:int;
		public var autoEnable:Boolean = true;
		
		public var text:TextField;
		public var index:TextField;
		
		public function SelectableButton() 
		{
			super();
			mouseChildren = false;
			buttonMode = true;
			selected = false;
			stop();
		};
		
		public function get selected():Boolean { return _selected; };
		
		public function set selected(value:Boolean):void 
		{
			_selected = value;
			if( autoEnable ) mouseEnabled = !value;
			gotoAndStop(value ? 2 : 1);
		};
		
		public function get data():Object { return _data; };
		
		public function set data(value:Object):void 
		{
			_data = value;
		};
		
		override public function get enabled():Boolean { return super.enabled; };
		
		override public function set enabled(value:Boolean):void 
		{
			super.enabled = value;
			mouseEnabled = value;
			alpha = value ? 1 : 0.4;
		};
	};
}